import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

class CopyOfdataSets implements Iterable<Map.Entry<String,Double>>{
	  public Iterator<Map.Entry<String,Double>> iterator() {		  
		  return trainingSamples.entrySet().iterator();
	    }
	HashMap<String,Double> trainingSamples = new HashMap<String,Double>();
	int size = trainingSamples.size();
	void readFromFile(String filename){
		try
		{
			BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename),"UTF-8"));
			int index = 1;
			String strLine;
			while ((strLine = br.readLine()) != null)
			{
				//System.out.println("["+strLine+"]");
				trainingSamples.put(strLine, 1.0);
			}
			size = trainingSamples.size();
			br.close();
		}catch(Exception e)
		{
			System.out.println("Error loading finle!!!");
			e.printStackTrace();
		}
		
	}
	void put(String features,Double weight){
		trainingSamples.put(features,weight);
		size = trainingSamples.size();
	}
	Double get(String features){
		return trainingSamples.get(features);
	}
	void initWeight(int size){
		for(Map.Entry<String,Double> entry :trainingSamples.entrySet()){
			entry.setValue(1.0/size);
		}
	}
	void normalizeWeight(){
		double weightSum = 0;
		for(Map.Entry<String,Double> entry :trainingSamples.entrySet()){
			weightSum += entry.getValue();
		}
		for(Map.Entry<String,Double> entry :trainingSamples.entrySet()){
			entry.setValue(entry.getValue()/weightSum);
		}
	}
}